import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import org.junit.jupiter.api.Test;
import org.yaml.snakeyaml.Yaml;

/**
 * @author zhyu
 * @date 2021/2/4 17:15
 */
public class YmlDemo {
    
    @Test
    public void test() throws FileNotFoundException {
//        Object load = Yaml.load(new File("D:\\code\\takeout\\shop\\src\\main\\resources\\application.yml"));
        Yaml yml = new Yaml();
        //配置文件路径
//        String path = Object.class.getResource("/").getPath().substring(1)+ "application.yml";
        InputStream reader = new FileInputStream(new File("D:\\code\\takeout\\shop\\src\\main\\resources\\application.yml"));
        //yml读取配置文件,指定返回类型为Map,Map中value类型为LinkedHashMap
        System.out.println(yml.loadAs(reader, JSONObject.class));
        
    }
}
